#include "interrupter.h"

/////////////////////////////// Port Declarations //////////////////////////////

handlesT handles;

/////////////////////////////// Diagnostic level ///////////////////////////////

Uns32 diagnosticLevel;

/////////////////////////// Diagnostic level callback //////////////////////////

static void setDiagLevel(Uns32 new) {
    diagnosticLevel = new;
}

/////////////////////////////////// Net Ports //////////////////////////////////

static void installNetPorts(void) {
	handles.intp = ppmOpenNetPort("intp");
}

////////////////////////////////// Constructor /////////////////////////////////

PPM_CONSTRUCTOR_CB(periphConstructor) {
	installNetPorts();
}

///////////////////////////////////// Main /////////////////////////////////////

int main(int argc, char *argv[]) {
    diagnosticLevel = 0;
    bhmInstallDiagCB(setDiagLevel);
    constructor();
	
	int i = 0;
	while(i < 10) {
		bhmWaitDelay(1000000000);
		ppmWriteNet(handles.intp, 666);
		bhmPrintf 	("Interrupt should have happend!\n");
		i++;
	}
	
	bhmWaitEvent(bhmGetSystemEvent(BHM_SE_END_OF_SIMULATION));
    destructor();
    return 0;
}

